package mss

import (
	"log"
	"net"

	"google.golang.org/grpc"
	"google.golang.org/grpc/grpclog"
)

func GRPCServer(Address string, callback func(s *grpc.Server)) {
	if callback == nil {
		grpclog.Fatalf("callback is nil")
		return
	}
	listen, error := net.Listen("tcp", Address)
	if error != nil {
		grpclog.Fatalf("Failed to listen: %v", error)
		return
	}
	server := grpc.NewServer()
	callback(server)
	log.Println("Listen on " + Address)
	server.Serve(listen)
}
